package com.example.emoiticon.adapter;
import com.example.emoiticon.FistActivity;
import com.example.emoiticon.SecondActivity;
import com.viewpagerindicator.IconPagerAdapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;
public class FragmentAdapter extends FragmentStatePagerAdapter implements IconPagerAdapter {
	 private Fragment mCurrentFragment;

     public Fragment getCurrentFragment() {
         return mCurrentFragment;
     }
	public FragmentAdapter(FragmentManager fm) {
		super(fm);
		// TODO Auto-generated constructor stub
	}
	 @Override
     public void setPrimaryItem(ViewGroup container, int position, Object object) {
         if (getCurrentFragment() != object) {
             mCurrentFragment = ((Fragment) object);
         }
         super.setPrimaryItem(container, position, object);
     }

	@Override
	public int getIconResId(int index) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Fragment getItem(int arg0) {
		// TODO Auto-generated method stub
	    Fragment fragment = new FistActivity();
        switch(arg0){
        case 0:
            fragment = new FistActivity();
            break;
        case 1:
            fragment = new SecondActivity();
            break;
        }
        return fragment;
	}
	 @Override
	    public CharSequence getPageTitle(int position){
	        String title = "";
	        switch(position){
	        case 0:
	            title = "Animation";
	            break;
	      case 1:
	            title = "Tedyberry";
	            break;
	        }
	        return title;
	    }
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 2;
	}

}
